home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Automatic 229347172001.psc / frmMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-05-15  |  42.2 KB  |  1,187 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form frmMain 
  4.    Caption         =   "Auto Error handling 1.0  - (c) 2001 written by adi barda 052-721721"
  5.    ClientHeight    =   8595
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   11880
  9.    Icon            =   "frmMain.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    LockControls    =   -1  'True
  12.    MaxButton       =   0   'False
  13.    ScaleHeight     =   8595
  14.    ScaleWidth      =   11880
  15.    StartUpPosition =   3  'Windows Default
  16.    Begin VB.CommandButton cmdShowInterface 
  17.       Caption         =   "Show interface"
  18.       Enabled         =   0   'False
  19.       Height          =   375
  20.       Left            =   4200
  21.       TabIndex        =   41
  22.       ToolTipText     =   "Show selected file interface"
  23.       Top             =   4590
  24.       Width           =   1425
  25.    End
  26.    Begin VB.TextBox txtControlPrefixes 
  27.       Height          =   255
  28.       Left            =   2580
  29.       TabIndex        =   40
  30.       Text            =   "cmd,chk,lbl,cbo,lst,txt,opt,img"
  31.       Top             =   7770
  32.       Width           =   3255
  33.    End
  34.    Begin VB.CheckBox chkIgnoreControlsPrefix 
  35.       Caption         =   "Ignore functions starting with:"
  36.       Height          =   255
  37.       Left            =   210
  38.       TabIndex        =   39
  39.       ToolTipText     =   "
  40.       Top             =   7740
  41.       Value           =   1  'Checked
  42.       Width           =   2385
  43.    End
  44.    Begin VB.CommandButton cmdUnSelectFunc 
  45.       Caption         =   "-"
  46.       Height          =   285
  47.       Left            =   10860
  48.       TabIndex        =   38
  49.       ToolTipText     =   "Un select"
  50.       Top             =   4590
  51.       Width           =   405
  52.    End
  53.    Begin VB.CommandButton cmdSelectFunc 
  54.       Caption         =   "+"
  55.       Height          =   285
  56.       Left            =   11310
  57.       TabIndex        =   37
  58.       ToolTipText     =   "Select all"
  59.       Top             =   4590
  60.       Width           =   405
  61.    End
  62.    Begin VB.CommandButton cmdUnSelectFiles 
  63.       Caption         =   "-"
  64.       Height          =   285
  65.       Left            =   6570
  66.       TabIndex        =   36
  67.       ToolTipText     =   "Un select"
  68.       Top             =   4590
  69.       Width           =   405
  70.    End
  71.    Begin VB.CommandButton cmdSelectFiles 
  72.       Caption         =   "+"
  73.       Height          =   285
  74.       Left            =   7020
  75.       TabIndex        =   35
  76.       ToolTipText     =   "Select all"
  77.       Top             =   4590
  78.       Width           =   405
  79.    End
  80.    Begin VB.CheckBox chkIgnoreOnErr 
  81.       Caption         =   "Ignore functions with ""ON ERROR"" commands"
  82.       Height          =   255
  83.       Left            =   210
  84.       TabIndex        =   34
  85.       ToolTipText     =   "
  86.       Top             =   7440
  87.       Value           =   1  'Checked
  88.       Width           =   3765
  89.    End
  90.    Begin VB.CommandButton cmdView 
  91.       Caption         =   "View"
  92.       Enabled         =   0   'False
  93.       Height          =   375
  94.       Left            =   2520
  95.       TabIndex        =   33
  96.       ToolTipText     =   "Compare original file with the new file"
  97.       Top             =   4590
  98.       Width           =   795
  99.    End
  100.    Begin VB.CommandButton cmdCommit 
  101.       Caption         =   "Commit"
  102.       Enabled         =   0   'False
  103.       Height          =   375
  104.       Left            =   1680
  105.       TabIndex        =   32
  106.       ToolTipText     =   "Add error handling to the selected files and functions"
  107.       Top             =   4590
  108.       Width           =   795
  109.    End
  110.    Begin VB.ListBox lstFunctions 
  111.       Height          =   4335
  112.       Left            =   7590
  113.       Sorted          =   -1  'True
  114.       Style           =   1  'Checkbox
  115.       TabIndex        =   30
  116.       TabStop         =   0   'False
  117.       Top             =   210
  118.       Width           =   4125
  119.    End
  120.    Begin VB.CommandButton cmdClear 
  121.       Caption         =   "Clear"
  122.       Height          =   375
  123.       Left            =   3360
  124.       TabIndex        =   29
  125.       ToolTipText     =   "Clear list"
  126.       Top             =   4590
  127.       Width           =   795
  128.    End
  129.    Begin VB.CommandButton cmdTransfer 
  130.       Caption         =   "Transfer"
  131.       Enabled         =   0   'False
  132.       Height          =   375
  133.       Left            =   9270
  134.       TabIndex        =   28
  135.       ToolTipText     =   "
  136.       Top             =   7650
  137.       Width           =   1125
  138.    End
  139.    Begin VB.CommandButton cmdExit 
  140.       Caption         =   "Exit"
  141.       Height          =   375
  142.       Left            =   10440
  143.       TabIndex        =   27
  144.       ToolTipText     =   "
  145.       Top             =   7650
  146.       Width           =   1245
  147.    End
  148.    Begin VB.Frame Frame1 
  149.       Caption         =   "Err handling:"
  150.       ForeColor       =   &H00FF0000&
  151.       Height          =   1575
  152.       Left            =   3270
  153.       TabIndex        =   16
  154.       Top             =   5280
  155.       Width           =   8385
  156.       Begin VB.OptionButton optUseErrFunc 
  157.          Caption         =   "Use Error handling function"
  158.          ForeColor       =   &H00404080&
  159.          Height          =   255
  160.          Left            =   4350
  161.          TabIndex        =   26
  162.          Top             =   210
  163.          Value           =   -1  'True
  164.          Width           =   2295
  165.       End
  166.       Begin VB.OptionButton optUseFreeText 
  167.          Caption         =   "Use free text"
  168.          ForeColor       =   &H00404080&
  169.          Height          =   255
  170.          Left            =   90
  171.          TabIndex        =   25
  172.          Top             =   210
  173.          Width           =   1305
  174.       End
  175.       Begin VB.TextBox txtExtraParam 
  176.          Height          =   285
  177.          Left            =   5640
  178.          TabIndex        =   24
  179.          Text            =   "Err_Handle_Mode"
  180.          Top             =   1200
  181.          Width           =   1755
  182.       End
  183.       Begin VB.CheckBox chkErrObj 
  184.          Caption         =   "Err object"
  185.          Height          =   255
  186.          Left            =   7110
  187.          TabIndex        =   23
  188.          Top             =   810
  189.          Value           =   1  'Checked
  190.          Width           =   1065
  191.       End
  192.       Begin VB.CheckBox chkModuleName 
  193.          Caption         =   "Module name"
  194.          Height          =   255
  195.          Left            =   4440
  196.          TabIndex        =   22
  197.          Top             =   810
  198.          Value           =   1  'Checked
  199.          Width           =   1305
  200.       End
  201.       Begin VB.CheckBox chkExtraParam 
  202.          Caption         =   "Extra param"
  203.          Height          =   255
  204.          Left            =   4440
  205.          TabIndex        =   21
  206.          Top             =   1170
  207.          Value           =   1  'Checked
  208.          Width           =   1185
  209.       End
  210.       Begin VB.CheckBox chkProcName 
  211.          Caption         =   "Proc name"
  212.          Height          =   255
  213.          Left            =   5820
  214.          TabIndex        =   20
  215.          Top             =   810
  216.          Value           =   1  'Checked
  217.          Width           =   1185
  218.       End
  219.       Begin VB.TextBox txtFuncName 
  220.          Height          =   285
  221.          Left            =   5370
  222.          TabIndex        =   18
  223.          Text            =   "Err_Handler"
  224.          Top             =   480
  225.          Width           =   1995
  226.       End
  227.       Begin VB.TextBox txtErrHndl 
  228.          Enabled         =   0   'False
  229.          Height          =   975
  230.          Left            =   90
  231.          MultiLine       =   -1  'True
  232.          ScrollBars      =   3  'Both
  233.          TabIndex        =   17
  234.          Text            =   "frmMain.frx":0442
  235.          Top             =   450
  236.          Width           =   3915
  237.       End
  238.       Begin VB.Label Label1 
  239.          BackStyle       =   0  'Transparent
  240.          Caption         =   "Func name:"
  241.          Height          =   255
  242.          Index           =   7
  243.          Left            =   4380
  244.          TabIndex        =   19
  245.          Top             =   480
  246.          Width           =   945
  247.       End
  248.    End
  249.    Begin VB.TextBox txtExitLabel 
  250.       Height          =   285
  251.       Left            =   1200
  252.       TabIndex        =   14
  253.       Text            =   "Exit_Proc"
  254.       Top             =   5640
  255.       Width           =   1995
  256.    End
  257.    Begin VB.TextBox txtTabLength 
  258.       Height          =   285
  259.       Left            =   1200
  260.       TabIndex        =   12
  261.       Text            =   "4"
  262.       Top             =   6720
  263.       Width           =   885
  264.    End
  265.    Begin VB.CheckBox chkApplyOnFunc 
  266.       Caption         =   "Apply on functions"
  267.       Height          =   255
  268.       Left            =   2130
  269.       TabIndex        =   11
  270.       ToolTipText     =   "
  271.       Top             =   7110
  272.       Value           =   1  'Checked
  273.       Width           =   1815
  274.    End
  275.    Begin VB.CheckBox chkApplyOnProc 
  276.       Caption         =   "Apply on procedures"
  277.       Height          =   255
  278.       Left            =   210
  279.       TabIndex        =   10
  280.       ToolTipText     =   "
  281.       Top             =   7110
  282.       Value           =   1  'Checked
  283.       Width           =   1815
  284.    End
  285.    Begin VB.TextBox txtUpperGap 
  286.       Height          =   285
  287.       Left            =   1200
  288.       TabIndex        =   9
  289.       Text            =   "3"
  290.       Top             =   6060
  291.       Width           =   885
  292.    End
  293.    Begin VB.TextBox txtLowerGap 
  294.       Height          =   285
  295.       Left            =   1200
  296.       TabIndex        =   8
  297.       Text            =   "2"
  298.       Top             =   6390
  299.       Width           =   885
  300.    End
  301.    Begin VB.TextBox txtErrLbl 
  302.       Height          =   285
  303.       Left            =   1200
  304.       TabIndex        =   7
  305.       Text            =   "Err_Proc"
  306.       Top             =   5310
  307.       Width           =   1995
  308.    End
  309.    Begin VB.ListBox lstSelectedFiles 
  310.       Height          =   4335
  311.       Left            =   60
  312.       Style           =   1  'Checkbox
  313.       TabIndex        =   2
  314.       TabStop         =   0   'False
  315.       Top             =   210
  316.       Width           =   7365
  317.    End
  318.    Begin VB.CommandButton cmdBrows 
  319.       Caption         =   "Brows"
  320.       Height          =   375
  321.       Left            =   60
  322.       TabIndex        =   1
  323.       ToolTipText     =   "Add vb project to the list"
  324.       Top             =   4590
  325.       Width           =   735
  326.    End
  327.    Begin MSComDlg.CommonDialog dlg1 
  328.       Left            =   4050
  329.       Top             =   6960
  330.       _ExtentX        =   847
  331.       _ExtentY        =   847
  332.       _Version        =   393216
  333.    End
  334.    Begin VB.CommandButton cmdDefine 
  335.       Caption         =   "Define"
  336.       Enabled         =   0   'False
  337.       Height          =   375
  338.       Left            =   840
  339.       TabIndex        =   0
  340.       ToolTipText     =   "Parse the files and find the functions"
  341.       Top             =   4590
  342.       Width           =   795
  343.    End
  344.    Begin VB.Label Label1 
  345.       Caption         =   "Selected functions:"
  346.       ForeColor       =   &H00FF0000&
  347.       Height          =   285
  348.       Index           =   0
  349.       Left            =   7590
  350.       TabIndex        =   31
  351.       Top             =   0
  352.       Width           =   1515
  353.    End
  354.    Begin VB.Label Label1 
  355.       BackStyle       =   0  'Transparent
  356.       Caption         =   "Exit label:"
  357.       Height          =   255
  358.       Index           =   8
  359.       Left            =   210
  360.       TabIndex        =   15
  361.       Top             =   5640
  362.       Width           =   945
  363.    End
  364.    Begin VB.Label Label1 
  365.       BackStyle       =   0  'Transparent
  366.       Caption         =   "Tab length:"
  367.       Height          =   285
  368.       Index           =   6
  369.       Left            =   210
  370.       TabIndex        =   13
  371.       Top             =   6690
  372.       Width           =   945
  373.    End
  374.    Begin VB.Label Label1 
  375.       BackStyle       =   0  'Transparent
  376.       Caption         =   "Lower gap:"
  377.       Height          =   285
  378.       Index           =   5
  379.       Left            =   210
  380.       TabIndex        =   6
  381.       Top             =   6360
  382.       Width           =   945
  383.    End
  384.    Begin VB.Label Label1 
  385.       BackStyle       =   0  'Transparent
  386.       Caption         =   "Err label:"
  387.       Height          =   255
  388.       Index           =   4
  389.       Left            =   210
  390.       TabIndex        =   5
  391.       Top             =   5310
  392.       Width           =   945
  393.    End
  394.    Begin VB.Label Label1 
  395.       BackStyle       =   0  'Transparent
  396.       Caption         =   "Upper gap:"
  397.       Height          =   285
  398.       Index           =   3
  399.       Left            =   210
  400.       TabIndex        =   4
  401.       Top             =   6030
  402.       Width           =   945
  403.    End
  404.    Begin VB.Label Label1 
  405.       Caption         =   "Selected files:"
  406.       ForeColor       =   &H00FF0000&
  407.       Height          =   285
  408.       Index           =   2
  409.       Left            =   60
  410.       TabIndex        =   3
  411.       Top             =   0
  412.       Width           =   1065
  413.    End
  414. Attribute VB_Name = "frmMain"
  415. Attribute VB_GlobalNameSpace = False
  416. Attribute VB_Creatable = False
  417. Attribute VB_PredeclaredId = True
  418. Attribute VB_Exposed = False
  419. Option Explicit
  420. 'Private m_SourceFiles()         As String
  421. Const C_MODULE_NAME = 0
  422. Const C_PROC_NAME = 1
  423. Const C_SELECTED = 2
  424. Const C_IGNORED = 3
  425. Private m_FilesCounter          As Long
  426. Private m_bAvoidClick           As Boolean
  427. Private m_AFunctions()          As Variant
  428. Private m_AControlsPrefix()     As String
  429. '* Function: AddErrHandling
  430. '* Purpose: Add error handling to a certain file
  431. Private Function AddErrHandling(ByVal sFilePath As String, _
  432.                                 ByVal FileNum As Long, _
  433.                                 Optional ByVal UseDefinition As Boolean = False) As Boolean
  434.     'Purpose: Add error handling to the temporary file
  435.     '         if UseDefinition = true,
  436.     On Error GoTo Err_Proc
  437.     Const PROCESS_REMARK = "'"
  438.     Dim ff          As Long 'source file
  439.     Dim ffDest      As Long 'dest file
  440.     Dim ffDesc      As Long 'description file
  441.     Dim s           As String
  442.     Dim sline       As String
  443.     Dim sDest       As String
  444.     Dim sDestFile   As String
  445.     Dim sModuleName As String 'current module name
  446.     Dim sProcName   As String 'current procedure name
  447.     Dim ProcIndex   As Long 'function index in array
  448.     Dim i           As Long
  449.     Dim bStartSub     As Boolean 'recognize function
  450.     Dim bStartFunc    As Boolean 'recognize function
  451.     Dim bEndSub       As Boolean 'recognize end of sub or function
  452.     Dim bAddOnErr     As Boolean 'flag saying need to add on error statement
  453.     Dim bOnErrorAdded As Boolean 'flag indicated whether on error added
  454.     Dim bAddErrLbl    As Boolean
  455.     Dim bHasOnError   As Boolean 'the function allredy has on error
  456.     Dim bFoundModuleName As Boolean 'flag-found thew module name
  457.     Dim iTopIndex     As Long 'optimization flag
  458.     Dim oDir          As Scripting.FileSystemObject
  459.     Dim sDesc         As String 'temp variable to store function description
  460.     Dim iDesc         As Long 'function description counter
  461.     'Init interface description array
  462.     ReDim g_InterfaceDesc(0)
  463.     sDesc = ""
  464.     iDesc = 1
  465.     Set oDir = New Scripting.FileSystemObject
  466.     'gets the array size-number of functions in the system
  467.     iTopIndex = UBound(m_AFunctions, 2)
  468.     If m_AFunctions(0, 0) <> -1 Then iTopIndex = iTopIndex + 1 'case its not the first time
  469.     'init vars
  470.     sModuleName = ""
  471.     sProcName = ""
  472.     'open source file
  473.     ff = FreeFile
  474.     Open sFilePath For Input As #ff
  475.     'open temp dest file
  476.     ffDest = FreeFile
  477.     sDestFile = GetDestFileName(sFilePath)
  478.     'ensures that the temp files folder exists
  479.     If Not oDir.FolderExists(App.Path & "\DestTmp") Then
  480.         oDir.CreateFolder App.Path & "\DestTmp"
  481.     End If
  482.     Open App.Path & "\DestTmp\" & sDestFile For Output As #ffDest
  483.     'open description file
  484.     ffDesc = FreeFile()
  485.     s = App.Path & "\DestTmp\" & sDestFile & ".desc"
  486.     Open s For Output As #ffDesc
  487.     'init algorithm flags
  488.     s = ""
  489.     bStartSub = False
  490.     bEndSub = False
  491.     bAddOnErr = False
  492.     bOnErrorAdded = False
  493.     bAddErrLbl = False
  494.     bStartFunc = False
  495.     bFoundModuleName = False
  496.     'main scanning loop
  497.     Do Until EOF(ff)
  498.         'read the current line from the file
  499.         Line Input #ff, sline
  500.         
  501.         'init dest line
  502.         sDest = ""
  503.         
  504.         '*Check for the module name
  505.         If Not bFoundModuleName Then
  506.             sModuleName = GetModuleName(sline)
  507.             bFoundModuleName = (LenB(sModuleName) <> 0)
  508.             If bFoundModuleName Then
  509.                 sDesc = vbNewLine & "*****   " & sModuleName & " INTERFACE   *****" & vbNewLine
  510.                 For i = 1 To 100
  511.                     sDesc = sDesc & "-"
  512.                 Next i
  513.                 sDesc = sDesc & vbNewLine & "Printed in " & Now & vbNewLine
  514.                 sDesc = sDesc & vbNewLine & vbNewLine
  515.             End If
  516.         End If
  517.         
  518.         '* check if its a begining of a sub or function
  519.         '* Check subs:
  520.         If (Not bStartSub) Then
  521.             If LCase(Left$(sline, 11)) = "public sub " Then
  522.                 sProcName = GetProcName(sline, 12)
  523.                 bStartSub = ((Me.chkApplyOnProc.Value = 1) And (FunctionSelected(FileNum, sProcName, UseDefinition)))
  524.                 If bStartSub Then bHasOnError = False
  525.             ElseIf LCase(Left$(sline, 4)) = "sub " Then
  526.                 sProcName = GetProcName(sline, 5)
  527.                 bStartSub = ((Me.chkApplyOnProc.Value = 1) And (FunctionSelected(FileNum, sProcName, UseDefinition)))
  528.                 If bStartSub Then bHasOnError = False
  529.             ElseIf LCase(Left$(sline, 12)) = "private sub " Then
  530.                 sProcName = GetProcName(sline, 13)
  531.                 bStartSub = ((Me.chkApplyOnProc.Value = 1) And (FunctionSelected(FileNum, sProcName, UseDefinition)))
  532.                 If bStartSub Then bHasOnError = False
  533.             End If
  534.         Else
  535.             If LCase(Left$(sline, 7)) = "end sub" Then
  536.                 bEndSub = True
  537.             End If
  538.         End If
  539.         
  540.         '* Check functions:
  541.         If (Not bStartFunc) Then
  542.             If LCase(Left$(sline, 16)) = "public function " Then
  543.                 sProcName = GetProcName(sline, 17)
  544.                 bStartFunc = ((Me.chkApplyOnFunc.Value = 1) And (FunctionSelected(FileNum, sProcName, UseDefinition)))
  545.                 If bStartFunc Then bHasOnError = False
  546.             ElseIf LCase(Left$(sline, 9)) = "function " Then
  547.                 sProcName = GetProcName(sline, 10)
  548.                 bStartFunc = ((Me.chkApplyOnFunc.Value = 1) And (FunctionSelected(FileNum, sProcName, UseDefinition)))
  549.                 If bStartFunc Then bHasOnError = False
  550.             ElseIf LCase(Left$(sline, 17)) = "private function " Then
  551.                 sProcName = GetProcName(sline, 18)
  552.                 bStartFunc = ((Me.chkApplyOnFunc.Value = 1) And (FunctionSelected(FileNum, sProcName, UseDefinition)))
  553.                 If bStartFunc Then bHasOnError = False
  554.             End If
  555.         Else
  556.             If LCase(Left$(sline, 12)) = "end function" Then
  557.                 bEndSub = True
  558.             End If
  559.         End If
  560.         
  561.         If ((bStartSub) And (Not bAddOnErr)) Or ((bStartFunc) And (Not bAddOnErr)) Then
  562.             '* check if after the current row i should insert on error goto..
  563.             bAddOnErr = CheckAddOnErr(sline)
  564.             sDesc = sDesc & sline & vbNewLine 'function description
  565.             iDesc = 1
  566.         End If
  567.         
  568.         'Build function description:
  569.         If (InStr(1, Trim(sline), PROCESS_REMARK) = 1) Then  'print the remark only if it starts the line
  570.             If (bStartSub Or bStartFunc) Then
  571.                 sDesc = sDesc & vbNewLine & Space$(4) & iDesc & ")  " & sline & vbNewLine
  572.                 iDesc = iDesc + 1
  573.             Else
  574.                 sDesc = sDesc & vbNewLine & sline & vbNewLine
  575.             End If
  576.             
  577.         End If
  578.         
  579.         '*check if the function allready has on error statement
  580.         If Not bHasOnError Then
  581.             bHasOnError = (InStr(1, LCase$(sline), "on error") > 0)
  582.         End If
  583.         
  584.         
  585.         
  586.         If ((bStartSub) And (bAddOnErr) And (Not bOnErrorAdded)) Or _
  587.            ((bStartFunc) And (bAddOnErr) And (Not bOnErrorAdded)) Then
  588.             '* Add on error goto...
  589.             sDest = sDest & sline
  590.             For i = 1 To CLng(Me.txtUpperGap.Text)
  591.                 sDest = sDest & vbNewLine
  592.             Next i
  593.             
  594.             sDest = sDest & Space$(CLng(Me.txtTabLength.Text)) & "On error goto " & Me.txtErrLbl.Text
  595.             
  596.             bOnErrorAdded = True
  597.         End If
  598.         
  599.         
  600.         '*Check if its end of sub or function
  601.         If (bEndSub) Then
  602.             sDest = Me.txtExitLabel.Text & ":" & vbNewLine
  603.             If bStartFunc Then
  604.                 sDest = sDest & Space$(CLng(Me.txtTabLength.Text)) & "Exit function" & vbNewLine
  605.             Else
  606.                 sDest = sDest & Space$(CLng(Me.txtTabLength.Text)) & "Exit sub" & vbNewLine
  607.             End If
  608.             
  609.             '*Add label text
  610.             sDest = sDest & vbNewLine & vbNewLine
  611.             sDest = sDest & Me.txtErrLbl.Text & ":" & vbNewLine
  612.             
  613.             '*Add reference to err handling
  614.             If Me.optUseFreeText.Value Then
  615.                 sDest = sDest & Space$(CLng(Me.txtTabLength.Text)) & Me.txtErrHndl.Text & vbNewLine
  616.             Else
  617.                 sDest = sDest & GetErrFunctionConst(sModuleName, sProcName) & vbNewLine
  618.             End If
  619.             
  620.             '*Resume to exit point
  621.             sDest = sDest & Space$(CLng(Me.txtTabLength.Text)) & "Resume " & Me.txtExitLabel & vbNewLine
  622.             
  623.             
  624.             '*Update functions array:
  625.             If Not UseDefinition Then
  626.                 ReDim Preserve m_AFunctions(3, iTopIndex) 'allocates new memory unit
  627.                 m_AFunctions(C_MODULE_NAME, iTopIndex) = FileNum  'file num in lst
  628.                 m_AFunctions(C_PROC_NAME, iTopIndex) = sProcName  'function name
  629.                 m_AFunctions(C_SELECTED, iTopIndex) = 1  'put err handling by default
  630.                 m_AFunctions(C_IGNORED, iTopIndex) = Abs(((bHasOnError) And (Me.chkIgnoreOnErr.Value = 1)) Or (HasControlPrefix(sProcName))) 'ignore this function or not
  631.                 
  632.                 iTopIndex = iTopIndex + 1
  633.             End If
  634.             
  635.             'insert lower gap space
  636.             For i = 1 To CLng(Me.txtLowerGap.Text)
  637.                 sDest = sDest & vbNewLine
  638.             Next i
  639.             sDest = sDest & sline
  640.             sDesc = sDesc & vbNewLine & sline & vbNewLine 'function description
  641.             
  642.             'print to description file
  643.             Print #ffDesc, sDesc
  644.                 
  645.             '*Clear variables:
  646.             bStartSub = False
  647.             bEndSub = False
  648.             bAddOnErr = False
  649.             bOnErrorAdded = False
  650.             bAddErrLbl = False
  651.             bStartFunc = False
  652.             sProcName = ""
  653.             sDesc = ""
  654.         End If
  655.         
  656.         
  657.         '* if nessesary insert default value
  658.         If LenB(sDest) = 0 Then
  659.             sDest = sline
  660.         End If
  661.         
  662.         'prints to destination temp file
  663.         Print #ffDest, sDest
  664.                
  665.     Loop
  666.     'close file ports
  667.     Close #ff
  668.     Close #ffDest
  669.     Close #ffDesc
  670. Exit_Proc:
  671. Exit Function
  672. Err_Proc:
  673.     Err_Handler " frmMain ", "AddErrHandling", Err, Err_Handle_Mode
  674.     'Resume
  675. Resume Exit_Proc
  676. End Function
  677. Private Function FunctionSelected(ByVal ModuleIndex As Long, ByVal sProcName As String, ByVal UseDefinition As Boolean, _
  678.                                   Optional ByRef ProcIndex As Long) As Boolean
  679.     On Error GoTo Err_Proc
  680.     '*Purpose: checks if the function was selected and not ignored
  681.     '*         function is ignored when user unmark its checkbox
  682.     Dim i           As Long
  683.     FunctionSelected = True
  684.     ProcIndex = -1
  685.     If Not UseDefinition Then Exit Function
  686.     'scan the functions array
  687.     For i = 0 To UBound(m_AFunctions, 2)
  688.         If (m_AFunctions(1, i) = sProcName) And (m_AFunctions(0, i) = ModuleIndex) Then
  689.             FunctionSelected = ((m_AFunctions(C_SELECTED, i) = 1) And (m_AFunctions(C_IGNORED, i) = 0))
  690.             ProcIndex = i
  691.             Exit For
  692.         End If
  693.     Next i
  694. Exit_Proc:
  695.     Exit Function
  696. Err_Proc:
  697.     Err_Handler " frmMain ", "FunctionSelected", Err, Err_Handle_Mode
  698.     Resume Exit_Proc
  699. End Function
  700. Private Function GetErrFunctionConst(ModuleName, ProcName) As String
  701.     '*Purpose: gets the code for referencing to global error handling function
  702.     On Error GoTo Err_Proc
  703.     Dim s           As String
  704.     'insert tab
  705.     s = Space$(CLng(Me.txtTabLength.Text)) & Me.txtFuncName.Text & " "
  706.     'insert function params
  707.     If Me.chkModuleName.Value = 1 Then s = s & Chr$(34) & ModuleName & Chr$(34) & ", "
  708.     If Me.chkProcName.Value = 1 Then s = s & Chr$(34) & ProcName & Chr$(34)
  709.     If Me.chkProcName.Value = 1 Then s = s & ",Err"
  710.     If Me.chkExtraParam.Value = 1 Then s = s & "," & Me.txtExtraParam.Text
  711.     GetErrFunctionConst = s
  712. Exit_Proc:
  713. Exit Function
  714. Err_Proc:
  715.     Err_Handler " frmMain ", "GetErrFunctionConst", Err, Err_Handle_Mode
  716. Resume Exit_Proc
  717. End Function
  718. Private Function CheckAddOnErr(ByVal CurrentLine As String) As Boolean
  719.     '*Purpose: check if the current line contains on error statement
  720.     On Error GoTo Err_Proc
  721.     CheckAddOnErr = (InStr(1, CurrentLine, ")") > 0)
  722. Exit_Proc:
  723. Exit Function
  724. Err_Proc:
  725.     Err_Handler " frmMain ", "CheckAddOnErr", Err, Err_Handle_Mode
  726. Resume Exit_Proc
  727. End Function
  728. Private Function CheckValidation() As Boolean
  729.     '*Purpose: check that all the nesesary fields has data
  730.     On Error GoTo Err_Proc
  731.     Dim obj     As Control
  732.     CheckValidation = False
  733.     For Each obj In frmMain
  734.         If TypeOf obj Is TextBox Then
  735.             If obj.Name <> "txtSource" And obj.Name <> "txtDest" Then
  736.                 If Trim(obj.Text) = "" Then
  737.                     Exit Function
  738.                 End If
  739.             End If
  740.             
  741.         End If
  742.         
  743.         
  744.     Next obj
  745.     CheckValidation = True
  746. Exit_Proc:
  747. Exit Function
  748. Err_Proc:
  749.     Err_Handler " frmMain ", "CheckValidation", Err, Err_Handle_Mode
  750. Resume Exit_Proc
  751. End Function
  752. Private Sub cmdBrows_Click()
  753.     '*Purpose:Brows for a vb project or just one more free file
  754.     '*        if vb project found than i load all its relevant code files
  755.     Dim sFileName       As String
  756.     Dim oDir            As Scripting.FileSystemObject
  757.     'open dialog box
  758.     dlg1.ShowOpen
  759.     Set oDir = New Scripting.FileSystemObject
  760.     'checks for valid file
  761.     If Not dlg1.CancelError Then
  762.         sFileName = dlg1.FileName
  763.         
  764.         'checks for file type
  765.         If oDir.GetExtensionName(sFileName) <> "vbp" Then
  766.             AddFileName sFileName 'other file
  767.         Else
  768.             AddProject sFileName 'vb project - add all relevant files
  769.         End If
  770.         
  771.     End If
  772.     'allow defining the selected files:
  773.     Me.cmdDefine.Enabled = (Me.lstSelectedFiles.ListCount > 0)
  774.     Me.cmdShowInterface.Enabled = False
  775. End Sub
  776. Private Sub AddProject(ByVal sFileName As String)
  777.     On Error GoTo Err_Proc
  778.     '*Purpose: adds the selected project (all its files) to the system manager
  779.     Dim oDir        As Scripting.FileSystemObject
  780.     Dim ff          As Long
  781.     Dim i           As Long
  782.     Dim sline       As String
  783.     Dim sObjectName As String
  784.     Dim sPath       As String
  785.     Set oDir = New Scripting.FileSystemObject
  786.     '*ensures backslash is exists
  787.     sPath = oDir.GetParentFolderName(sFileName)
  788.     If Right$(sPath, 1) <> "\" Then sPath = sPath & "\"
  789.     'open file port
  790.     ff = FreeFile
  791.     Open sFileName For Input As #ff
  792.     'scan vb project file
  793.     Do Until EOF(ff)
  794.         Line Input #ff, sline 'read next line in the project file
  795.         
  796.         'check for the next object:
  797.         If InStr(1, LCase$(sline), "form=") > 0 Then
  798.             i = InStr(1, sline, "=") + 1
  799.             sObjectName = Mid$(sline, i, Len(sline) - i + 1) 'find object name
  800.             
  801.             '*check that there is no (") in the object name
  802.             If InStr(1, sObjectName, Chr$(34)) = 0 Then
  803.                 AddFileName sPath & sObjectName 'add file to list
  804.             End If
  805.             
  806.         End If
  807.         
  808.         If InStr(1, LCase$(sline), "class=") > 0 Then
  809.             i = InStr(1, sline, ";") + 2
  810.             sObjectName = Mid$(sline, i, Len(sline) - i + 1)
  811.             AddFileName sPath & sObjectName 'add file to list
  812.         End If
  813.         
  814.         If InStr(1, LCase$(sline), "module=") > 0 Then
  815.             i = InStr(1, sline, ";") + 2
  816.             sObjectName = Mid$(sline, i, Len(sline) - i + 1)
  817.             AddFileName sPath & sObjectName 'add file to list
  818.         End If
  819.         
  820.         If InStr(1, LCase$(sline), "usercontrol=") > 0 Then
  821.             i = InStr(1, sline, "=") + 1
  822.             sObjectName = Mid$(sline, i, Len(sline) - i + 1)
  823.             AddFileName sPath & sObjectName 'add file to list
  824.         End If
  825.         
  826.     Loop
  827.     'close project file port
  828.     Close #ff
  829. Exit_Proc:
  830.     Exit Sub
  831. Err_Proc:
  832.     Err_Handler " frmMain ", "AddProject", Err, Err_Handle_Mode
  833.     Resume Exit_Proc
  834. End Sub
  835. Private Sub AddFileName(ByVal sFileName As String)
  836.     On Error GoTo Err_Proc
  837.     '*Purpose:adds new file to the files list
  838.     If LenB(sFileName) > 0 Then
  839.         If Not FileInList(sFileName) Then
  840.             lstSelectedFiles.AddItem sFileName
  841.             lstSelectedFiles.Selected(lstSelectedFiles.NewIndex) = True
  842.         End If
  843.     End If
  844. Exit_Proc:
  845.     Exit Sub
  846. Err_Proc:
  847.     Err_Handler " frmMain ", "AddFileName", Err, Err_Handle_Mode
  848.     Resume Exit_Proc
  849. End Sub
  850. Private Function FileInList(ByVal sFileName As String) As Boolean
  851.     'check if the specified file is allready in the list
  852.     On Error GoTo Err_Proc
  853.     Dim i           As Long
  854.     FileInList = False
  855.     For i = 0 To Me.lstSelectedFiles.ListCount - 1
  856.         FileInList = (sFileName = Me.lstSelectedFiles.List(i))
  857.         If FileInList Then Exit For
  858.     Next i
  859. Exit_Proc:
  860. Exit Function
  861. Err_Proc:
  862.     Err_Handler " frmMain ", "FileInList", Err, Err_Handle_Mode
  863. Resume Exit_Proc
  864. End Function
  865. Private Sub cmdClear_Click()
  866.     'clear all the files from the list
  867.     On Error GoTo Err_Proc
  868.     If MsgBox("Are you sure you want to clear the list ?", vbOKCancel Or vbQuestion) = vbOK Then
  869.         Me.lstSelectedFiles.Clear
  870.         Me.lstFunctions.Clear
  871.         ReDim m_AFunctions(3, 0)
  872.         
  873.         Me.cmdTransfer.Enabled = False
  874.         Me.cmdCommit.Enabled = False
  875.         Me.cmdDefine.Enabled = False
  876.         Me.cmdView.Enabled = False
  877.         Me.cmdShowInterface.Enabled = False
  878.         
  879.     End If
  880. Exit_Proc:
  881. Exit Sub
  882. Err_Proc:
  883.     Err_Handler " frmMain ", "cmdClear_Click", Err, Err_Handle_Mode
  884. Resume Exit_Proc
  885. End Sub
  886. Private Sub cmdCommit_Click()
  887.     'Purpose:Make the temporary files (generate error handling code)
  888.     ProcessFiles True 'parse and make new files using predefine rules like
  889.     '                  wich function needs err handling
  890.     Me.cmdView.Enabled = True
  891.     Me.cmdCommit.Enabled = False 'have to press "define" again
  892.     Me.cmdShowInterface.Enabled = False
  893. End Sub
  894. Private Sub cmdDefine_Click()
  895.     '*Parse the selected files and make temporary new files on the fly
  896.     ProcessFiles False 'dont use the previuse definition
  897.     Me.cmdCommit.Enabled = True
  898.     Me.cmdShowInterface.Enabled = True
  899.     If Me.lstSelectedFiles.ListCount > 0 Then
  900.         Me.lstSelectedFiles.ListIndex = 0 'focus on the first file
  901.         lstSelectedFiles_Click 'force showing the first file's functions
  902.     End If
  903. End Sub
  904. Private Sub ProcessFiles(Optional ByVal UseDefinitions As Boolean = False)
  905.     '*Purpose: parse all the selected files in the files list and generate
  906.     '          err handling code for all the selected functions
  907.     On Error GoTo Err_Proc
  908.     Dim i           As Long
  909.     If CheckValidation() Then
  910.         
  911.         '*Init functions array:
  912.         If Not UseDefinitions Then
  913.             ReDim m_AFunctions(3, 0)
  914.             m_AFunctions(0, 0) = -1
  915.         End If
  916.         
  917.         'Prepare controls prefix array
  918.         If Me.chkIgnoreControlsPrefix.Value = 1 Then
  919.             Me.txtControlPrefixes.Text = TrimEX(Me.txtControlPrefixes.Text) 'cut all spaces
  920.             m_AControlsPrefix = Split(Me.txtControlPrefixes.Text, ",")
  921.         Else
  922.             ReDim m_AControlsPrefix(0) 'clear array
  923.         End If
  924.         
  925.          'scan the files list
  926.          For i = 0 To Me.lstSelectedFiles.ListCount - 1
  927.              If Me.lstSelectedFiles.Selected(i) Then
  928.                  If LenB(Me.lstSelectedFiles.List(i)) > 0 Then
  929.                     'add err handling to the destination temp file
  930.                      AddErrHandling Me.lstSelectedFiles.List(i), i, UseDefinitions
  931.                  End If
  932.              End If
  933.              
  934.         Next i
  935.         Me.cmdTransfer.Enabled = True
  936.         'MsgBox "File definition completed successfully"
  937.     Else
  938.         MsgBox "Cannot commit because one of the parameters is wrong"
  939.         
  940.    End If
  941. Exit_Proc:
  942. Exit Sub
  943. Err_Proc:
  944.     Err_Handler " frmMain ", "cmdAdd_Click", Err, Err_Handle_Mode
  945. Resume Exit_Proc
  946. End Sub
  947. Private Sub cmdExit_Click()
  948.     Unload Me
  949. End Sub
  950. Private Sub cmdSelectFiles_Click()
  951.     'select all files
  952.     Dim i           As Long
  953.     For i = 0 To Me.lstSelectedFiles.ListCount - 1
  954.         Me.lstSelectedFiles.ListIndex = i
  955.         Me.lstSelectedFiles.Selected(i) = True
  956.     Next i
  957. End Sub
  958. Private Sub cmdSelectFunc_Click()
  959.     'select all functions
  960.     Dim i           As Long
  961.     For i = 0 To Me.lstFunctions.ListCount - 1
  962.         Me.lstFunctions.ListIndex = i
  963.         Me.lstFunctions.Selected(i) = True
  964.     Next i
  965. End Sub
  966. Private Sub cmdShowInterface_Click()
  967.     'view source code vs generated code
  968.     If LenB(Trim(Me.lstSelectedFiles.Text)) > 0 Then
  969.         frmView.ShowEX Me.lstSelectedFiles.Text, True
  970.     End If
  971. End Sub
  972. Private Sub cmdTransfer_Click()
  973.     '*Purpose: Replace the original files with the generated files
  974.     '          the generated files has err handling code in every function
  975.     On Error GoTo Err_Proc
  976.     Dim i           As Long
  977.     i = MsgBox("Are you sure you want to replace the original files with the " & _
  978.              "error handled files ?", vbOKCancel Or vbQuestion)
  979.     If i = vbOK Then
  980.         ReplaceFiles 'the final step
  981.         MsgBox "The file transfer completed successfully"
  982.     End If
  983. Exit_Proc:
  984. Exit Sub
  985. Err_Proc:
  986.     Err_Handler " frmMain ", "cmdTransfer_Click", Err, Err_Handle_Mode
  987. Resume Exit_Proc
  988. End Sub
  989. Private Sub cmdUnSelectFiles_Click()
  990.     'unselect all the files
  991.     Dim i           As Long
  992.     For i = 0 To Me.lstSelectedFiles.ListCount - 1
  993.         Me.lstSelectedFiles.ListIndex = i
  994.         Me.lstSelectedFiles.Selected(i) = False
  995.     Next i
  996. End Sub
  997. Private Sub cmdUnSelectFunc_Click()
  998.     'unselect all the functions
  999.     Dim i           As Long
  1000.     For i = 0 To Me.lstFunctions.ListCount - 1
  1001.         Me.lstFunctions.ListIndex = i
  1002.         Me.lstFunctions.Selected(i) = False
  1003.     Next i
  1004. End Sub
  1005. Private Sub cmdView_Click()
  1006.     'view source code vs generated code
  1007.     If LenB(Trim(Me.lstSelectedFiles.Text)) > 0 Then
  1008.         frmView.ShowEX Me.lstSelectedFiles.Text
  1009.     End If
  1010. End Sub
  1011. Private Sub Form_Load()
  1012.     On Error GoTo Err_Proc
  1013.     'init module-scope variables:
  1014.     Err_Handle_Mode = True
  1015.     m_FilesCounter = 0
  1016.     ReDim m_SourceFiles(0) 'source files container
  1017.     ReDim m_AFunctions(2, 0) 'functions definition
  1018.     ReDim m_AControlsPrefix(0) 'controls prefix
  1019.     m_AFunctions(0, 0) = -1 'no functions by default
  1020.     m_bAvoidClick = False
  1021. Exit_Proc:
  1022. Exit Sub
  1023. Err_Proc:
  1024.     Err_Handler " frmMain ", "Form_Load", Err, Err_Handle_Mode
  1025. Resume Exit_Proc
  1026. End Sub
  1027. Private Sub UpdateSelectedFile(ByVal Item As Long)
  1028.     On Error GoTo Err_Proc
  1029.     '*Purpose: Mark some function in the current file -
  1030.     '          whether to add err handling code or not
  1031.     Dim sProcName           As String
  1032.     Dim iModuleIndex        As Long
  1033.     Dim iProcIndex          As Long
  1034.     sProcName = Me.lstFunctions.Text 'function name
  1035.     iModuleIndex = Me.lstSelectedFiles.ListIndex 'module num
  1036.     FunctionSelected iModuleIndex, sProcName, True, iProcIndex
  1037.     'update the functions array
  1038.     m_AFunctions(2, iProcIndex) = Abs(Me.lstFunctions.Selected(Item))
  1039. Exit_Proc:
  1040.     Exit Sub
  1041. Err_Proc:
  1042.     Err_Handler " frmMain ", "UpdateSelectedFile", Err, Err_Handle_Mode
  1043.     Resume Exit_Proc
  1044. End Sub
  1045. Private Sub lstFunctions_ItemCheck(Item As Integer)
  1046.     If m_bAvoidClick Then Exit Sub
  1047.     UpdateSelectedFile Item 'update functions array
  1048. End Sub
  1049. Private Sub lstSelectedFiles_Click()
  1050.     'show all the functions in the module
  1051.     m_bAvoidClick = True
  1052.     ShowFunctions Me.lstSelectedFiles.ListIndex
  1053.     m_bAvoidClick = False
  1054. End Sub
  1055. Private Sub ShowFunctions(ByVal FileIndex As Long)
  1056.     On Error GoTo Err_Proc
  1057.     '*Purpose: show all the functions in the selected module
  1058.     Dim i               As Long
  1059.     Dim s               As String
  1060.     Dim sFuncName       As String
  1061.     Dim bFirstElement   As Boolean
  1062.     Dim bNoMore         As Boolean
  1063.     Dim iTopIndx        As Long
  1064.     bFirstElement = False
  1065.     bNoMore = False
  1066.     Me.lstFunctions.Clear
  1067.     i = 0
  1068.     iTopIndx = UBound(m_AFunctions, 2)
  1069.     'scan the functions array
  1070.     Do
  1071.         If m_AFunctions(0, i) = FileIndex Then
  1072.             If (Not bFirstElement) Then bFirstElement = (Not bFirstElement)
  1073.             sFuncName = m_AFunctions(1, i)
  1074.             Me.lstFunctions.AddItem sFuncName
  1075.             'If m_AFunctions(2, i) = 1 Then
  1076.                 Me.lstFunctions.Selected(Me.lstFunctions.NewIndex) = (m_AFunctions(2, i) = 1)
  1077.             'End If
  1078.             
  1079.         Else
  1080.             If bFirstElement Then 'no more relevant functions
  1081.                 bNoMore = True
  1082.             End If
  1083.             
  1084.         End If
  1085.         
  1086.         i = i + 1
  1087.         bNoMore = (i > iTopIndx)
  1088.         
  1089.     Loop Until bNoMore 'no more relevant functions
  1090. Exit_Proc:
  1091.     Exit Sub
  1092. Err_Proc:
  1093.     Err_Handler " frmMain ", "ShowFunctions", Err, Err_Handle_Mode
  1094.     Resume Exit_Proc
  1095. End Sub
  1096. Private Sub optUseErrFunc_Click()
  1097.     On Error GoTo Err_Proc
  1098.     CheckErrHandling
  1099. Exit_Proc:
  1100. Exit Sub
  1101. Err_Proc:
  1102.     Err_Handler " frmMain ", "optUseErrFunc_Click", Err, Err_Handle_Mode
  1103. Resume Exit_Proc
  1104. End Sub
  1105. Private Sub CheckErrHandling()
  1106.     'enable disable controls on the form
  1107.     On Error GoTo Err_Proc
  1108.     '*Enable / disable objects attached to err handling frame
  1109.     Me.chkErrObj.Enabled = Me.optUseErrFunc.Value
  1110.     Me.chkExtraParam.Enabled = Me.optUseErrFunc.Value
  1111.     Me.chkModuleName.Enabled = Me.optUseErrFunc.Value
  1112.     Me.chkProcName.Enabled = Me.optUseErrFunc.Value
  1113.     Me.txtExtraParam.Enabled = Me.optUseErrFunc.Value
  1114.     Me.txtErrHndl.Enabled = Me.optUseFreeText.Value
  1115. Exit_Proc:
  1116. Exit Sub
  1117. Err_Proc:
  1118.     Err_Handler " frmMain ", "CheckErrHandling", Err, Err_Handle_Mode
  1119. Resume Exit_Proc
  1120. End Sub
  1121. Private Sub optUseFreeText_Click()
  1122.     On Error GoTo Err_Proc
  1123.     CheckErrHandling
  1124. Exit_Proc:
  1125. Exit Sub
  1126. Err_Proc:
  1127.     Err_Handler " frmMain ", "optUseFreeText_Click", Err, Err_Handle_Mode
  1128. Resume Exit_Proc
  1129. End Sub
  1130. Private Sub ReplaceFiles()
  1131.     '* Well this is the final step: replacing the old files with the new files
  1132.     '  - wich has error handling code in all their functions
  1133.     On Error GoTo Err_Proc
  1134.     Dim i           As Long
  1135.     Dim sFile       As String
  1136.     On Error GoTo Err_Proc
  1137.     For i = 0 To Me.lstSelectedFiles.ListCount - 1
  1138.         If Me.lstSelectedFiles.Selected(i) Then
  1139.             sFile = GetDestFileName(Me.lstSelectedFiles.List(i))
  1140.             FileCopy App.Path & "\DestTmp\" & sFile, Me.lstSelectedFiles.List(i)
  1141.         End If
  1142.         
  1143.     Next i
  1144.     Exit Sub
  1145. Exit_Proc:
  1146. Exit Sub
  1147. Err_Proc:
  1148.     Err_Handler " frmMain ", "ReplaceFiles", Err, Err_Handle_Mode
  1149. Resume Exit_Proc
  1150. End Sub
  1151. Private Function HasControlPrefix(ByVal sProcName As String) As Boolean
  1152.     On Error GoTo Err_Proc
  1153.     'Purpose: check if the function's name has a control prefix
  1154.     '         if so - do not put error handling in that function
  1155.     Dim i           As Long
  1156.     Dim iIndx       As Long
  1157.     HasControlPrefix = False 'has no prefix by default
  1158.     sProcName = Trim(sProcName)
  1159.     For i = 0 To UBound(m_AControlsPrefix)
  1160.         iIndx = InStr(1, sProcName, m_AControlsPrefix(i))
  1161.         HasControlPrefix = (iIndx = 1 And Me.chkIgnoreControlsPrefix.Value = 1)
  1162.         If HasControlPrefix Then Exit For
  1163.     Next i
  1164.         
  1165. Exit_Proc:
  1166.     Exit Function
  1167. Err_Proc:
  1168.     Err_Handler " frmMain ", "HasControlPrefix", Err, Err_Handle_Mode
  1169.     Resume Exit_Proc
  1170. End Function
  1171. Private Function TrimEX(ByVal str As String) As String
  1172.     On Error GoTo Err_Proc
  1173.     Dim s           As String
  1174.     Dim i           As Long
  1175.     str = Trim(str)
  1176.     s = ""
  1177.     For i = 1 To Len(str)
  1178.         s = s & IIf(Mid$(str, i, 1) <> " ", Mid$(str, i, 1), "")
  1179.     Next i
  1180.     TrimEX = s
  1181. Exit_Proc:
  1182.     Exit Function
  1183. Err_Proc:
  1184.     Err_Handler " frmMain ", "TrimEX", Err, Err_Handle_Mode
  1185.     Resume Exit_Proc
  1186. End Function
  1187.